package com.ojoin.trade.supplyloan_core.utils.catchdata;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ojoin.trade.common.utils.LogUtils;
import com.ojoin.trade.common.utils.WaitUtil;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlPlatformUser;
import com.ojoin.trade.supplyloan_core.web.service.catchdata.ISLDataCatchBaseService;

public class MyCatchDataThreadNoMonitor implements Runnable {

	public static final Logger log = LoggerFactory
			.getLogger(MyCatchDataThreadNoMonitor.class);

	/*public static final Map<Integer, TbSlPlatformUser> map = Collections
			.synchronizedMap(new HashMap<Integer, TbSlPlatformUser>());*/

	private TbSlPlatformUser user;
	private ISLDataCatchBaseService service;

	// 任务编号

	public MyCatchDataThreadNoMonitor(TbSlPlatformUser user,
			ISLDataCatchBaseService service) {

		this.user = user;
		this.service = service;
	} 

	@Override
	public void run() {
		try {

			WaitUtil.waitTimeSeconds(5);

			LogUtils.info(log,
					"platformName->" + user.getPlatformName() + " joinid->"
							+ user.getIdOfTbMerchantUser() + " userid --> "
							+ user.getId() + "   username->" + user.getUsername()
							+ " 抓取数据开始.");
			
			service.catchData(user);
			
			LogUtils.info(log,
					"platformName->" + user.getPlatformName() + " joinid->"
							+ user.getIdOfTbMerchantUser() + " userid --> "
							+ user.getId() + " username->" + user.getUsername()
							+ " 抓取数据执行完毕.");

		} catch (Exception e) {
			LogUtils.info(log, 
					"platformName->" + user.getPlatformName() + " joinid->"
							+ user.getIdOfTbMerchantUser() + " userid --> "
							+ user.getId() + " username->" + user.getUsername()
							+ " 抓取数据失败.");  
			LogUtils.error(log,e); 
			
		} finally { 
			//map.remove(this.user.getId());
			/*LogUtils.info(log, "userid --> " + user.getId()
					+ "待抓取数据平台账号 ids--"+map.keySet().size()+">" + map.keySet());*/
			
			
		}
	}

}
